home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-1.iso / games / lorri4.zip / OBJECT.SCR < prev    next >
Text File  |  1995-09-24  |  17KB  |  469 lines

  1. !
  2. ! Default script OBJECT.SCR.
  3. !
  4. ! This is the default script for handling objects.  It is called whenever
  5. ! an object is manipulated (Talk, Get, Drop, Wear, Remove, Look, Examine,
  6. ! Invoke, Use and Exit) under the following conditions:
  7. !
  8. ! a) If the object has a script assigned to it, that script is called
  9. !    first.
  10. ! b) If the object's script terminates with CONTINUE, or if the object
  11. !    does not have a script, then this script is called.
  12. !
  13. ! You may modify this script at will, but one thing to remember is that
  14. ! this script should NEVER terminate with CONTINUE.  The reason is that
  15. ! objects may explicitly state that their script is 'OBJECT', in which
  16. ! case a 'CONTINUE' would execute this script twice! (Once as the script
  17. ! assigned to the object, and another time because the script ended with
  18. ! continue).
  19. !
  20. ! (c) DC Software, 1992
  21. !
  22.  
  23. !------------------------------------------------------------------------!
  24. :@TALK ! Talk to the object or npc !
  25. !------------------------------------------------------------------------!
  26.   ! This script is called whenever the object or NPC you tried to talk
  27.   ! to does not have it's own script for handling talking. Thus, it just
  28.   ! prints a standard message.  Since nothing really happens here, we
  29.   ! omit the check to see if the player is alive.
  30.  
  31.   ! gosub STILLKICKING; - don't check !
  32.   if npc.count then
  33.     writeln( "The ", npc.type, " has nothing to say.." );
  34.   else
  35.     writeln( "How do you talk to an ", object.type, "?" );
  36.   endif;
  37.   STOP;
  38.  
  39. !------------------------------------------------------------------------!
  40. :@GET ! Get the object (pick it up) !
  41. !------------------------------------------------------------------------!
  42.   if npc.count then writeln( "You can't do that.." ); STOP; endif;
  43.   if object.endgame = END_ON_GET then  ! Game ends on a GET of this object !
  44.     if object.endtext > 0 then         ! .. this text is displayed first.. !
  45.       readtext( object.endtext );
  46.     endif;                             ! .. then the game ends. !
  47.     ENDGAME;
  48.   endif;
  49.   if object.type = CHEST and object.locktype then ! Locked !
  50.     writeln( "You must first UNLOCK the chest, then GET the gold!" );
  51.   elsif object.type = CHEST or object.type = GOLDSACK then
  52.     if object.value = 0 then
  53.       L(1) = object.count * player.hp * 10 + random( 100 ) + 1;
  54.     else
  55.       L(1) = object.value * object.count;
  56.       if L(1) <= 0 then
  57.         L(1) = object.value;
  58.       endif;
  59.     endif;
  60.     writeln( "Got ", $L1, " (gold pieces)."  );
  61.     group.gold = group.gold + L(1);
  62.     vanish( object );
  63.   elsif object.type = FOOD and object.class = 0 then
  64.     writeln( "Got ", object.count, " units of food." );
  65.     group.food = group.food + object.count;
  66.     vanish( object );
  67.   elsif object.weight = 999 then
  68.     writeln( "The ", object.name, " is much too heavy." );
  69.   elsif object.weight = 998 then
  70.     writeln( "The ", object.name, " is can't be moved." );
  71.   elsif object.weight = 997 then
  72.     writeln( "Why would you want to take the ", object.name, "?" );
  73.   elsif object.weight > 255 then
  74.     writeln( "You can't move it!" );
  75.   elsif object.weight > player.mload then
  76.     writeln( "You are not strong enough to carry it!" );
  77.   elsif object.weight > 1 and object.weight + player.load > player.mload then
  78.     writeln( "Your load is too heavy!" );
  79.   elsif object.type = THING then
  80.     writeln( "Please leave the ", object.name, " alone" );
  81.   else
  82.     L(0) = object.count;
  83.     move( object, player.bp );  ! OBJECT does not exist after MOVE !
  84.     if success then
  85.       writeln("Got ", L(0), " ", player.bp.name );
  86.     elsif object.count = L(0) then
  87.       writeln("You couldn't carry it");
  88.     else
  89.       writeln("You could only carry ", L(0) - object.count, " of them." );
  90.     endif;
  91.   endif;
  92.   STOP;
  93.  
  94. !------------------------------------------------------------------------!
  95. :@DROP      ! Drop the object on the floor !
  96. !------------------------------------------------------------------------!
  97.   if curritem.count then
  98.     runscript( "CURRITEM", DROP );
  99.   endif;
  100.   if object.count then
  101.     writeln( "DROP has no meaning for an OBJECT not being carried!" );
  102.   else
  103.     writeln( "@DROP entry called in OBJECT script with no OBJECT!" );
  104.   endif;
  105.   STOP;
  106.  
  107. !------------------------------------------------------------------------!
  108. :@WEAR      ! Wear or Wield the object !
  109. !------------------------------------------------------------------------!
  110.   if curritem.count then
  111.     runscript( "CURRITEM", WEAR );
  112.   endif;
  113.   if object.count then
  114.     writeln( "WEAR has no meaning for an OBJECT not being carried!" );
  115.   else
  116.     writeln( "@WEAR entry called in OBJECT script with no OBJECT!" );
  117.   endif;
  118.   STOP;
  119.  
  120. !------------------------------------------------------------------------!
  121. :@REMOVE    ! Remove an object !
  122. !------------------------------------------------------------------------!
  123.   if curritem.count then
  124.     runscript( "CURRITEM", REMOVE );
  125.   endif;
  126.   if object.count then
  127.     writeln( "REMOVE has no meaning for an OBJECT not being carried!" );
  128.   else
  129.     writeln( "@REMOVE entry called in OBJECT script with no OBJECT!" );
  130.   endif;
  131.   STOP;
  132.  
  133. !------------------------------------------------------------------------!
  134. :@LOOK      ! Look at an object                                          !
  135. !------------------------------------------------------------------------!
  136.   L(255) = FALSE;   ! Do not give DETAILED description !
  137.   gosub DESCRIBE;
  138.   STOP;
  139.  
  140. !------------------------------------------------------------------------!
  141. :@EXAMINE   ! Examine the object in detail                               !
  142. !------------------------------------------------------------------------!
  143.   L(255) = TRUE;   ! Give DETAILED description !
  144.   gosub DESCRIBE;
  145.   STOP;
  146.  
  147. !------------------------------------------------------------------------!
  148. :@INVOKE  ! Invoke an object we are carrying..
  149. !------------------------------------------------------------------------!
  150.   if curritem.count then
  151.     runscript( "CURRITEM", INVOKE );
  152.   endif;
  153.   if object.count then
  154.     writeln( "INVOKE has no meaning for an OBJECT not being carried!" );
  155.   else
  156.     writeln( "@INVOKE entry called in OBJECT script with no OBJECT!" );
  157.   endif;
  158.   STOP;
  159.  
  160. !------------------------------------------------------------------------!
  161. :@USE ! Use an object laying on the ground before us..
  162. !------------------------------------------------------------------------!
  163. !
  164. ! Called when an object that is laying on the ground is 'used'.  Note that
  165. ! 'use' means different things for different object types, and that in 
  166. ! order to invoke an item you have 'get' it and sometimes 'wear' it.
  167. !
  168.   if object.endgame = END_ON_USE then
  169.     if object.endtext > 0 then         ! .. this text is displayed first.. !
  170.       readtext( object.endtext );
  171.     endif;                             ! .. then the game ends. !
  172.     ENDGAME;
  173.   endif;
  174.  
  175. ! The CONTROL script checks the distance, so we don't have to
  176. ! do it here. However, if we wanted to, we could do it like this...
  177. ! if abs(object.x - player.x) > 1 or abs(object.y - player.y) > 1 then
  178. !   writeln( "You can't reach the ", object.name );
  179. !   STOP;
  180. ! endif;
  181.  
  182.   on object.type goto
  183.    USE_FOOD,     USE_WEAPON,     USE_AMMO,      USE_ARMOR,      USE_SHIELD,
  184.    USE_AMULET,   USE_RING,       USE_POTION,    USE_SCROLL,     USE_STAFF,
  185.    USE_CHEST,    USE_KEYS,       USE_GEMS,      USE_BOOK,       USE_GOLDSACK,
  186.    USE_TORCH,    USE_LANTERN,    USE_ROPE,      USE_HOOKS,      USE_MIRROR,
  187.    USE_SIGN,     USE_VEHICLE,    USE_DOOR,      USE_THING;
  188.  
  189.   :USE_THING
  190.   writeln( "I don't know what to do with the ", object.name );
  191.   STOP;
  192.  
  193.   :USE_FOOD
  194.   :USE_POTION
  195.      if object.class then
  196.        writeln( "You must 'get' it, then 'quaff' (eat) it.." );
  197.      else
  198.        writeln( "Just 'get' it.." );
  199.      endif;
  200.      STOP;
  201.  
  202.   :USE_GEMS
  203.   :USE_SCROLL
  204.      writeln( "You must first 'get' it, then 'invoke' it.." );
  205.      STOP;
  206.  
  207.   :USE_AMULET
  208.   :USE_RING
  209.   :USE_ARMOR
  210.   :USE_WEAPON
  211.   :USE_SHIELD
  212.   :USE_STAFF
  213.      writeln( "You must first 'get' it, then 'wear' or 'wield' it.." );
  214.      STOP;
  215.  
  216.   :USE_AMMO
  217.      writeln( "Just carry it in your backpack.  If you 'wield' a " );
  218.      writeln( "weapon that uses this type of ammo, it will get used" );
  219.      writeln( "automaticly." );
  220.      STOP;
  221.  
  222.   :USE_CHEST
  223.      ! Unlock the chest !
  224.      if object.locktype then
  225.        gosub UNLOCK_OBJECT;
  226.        if object.locktype = 0 then
  227.          STOP; 
  228.        endif;
  229.        writeln( "You don't have the right key!  Break the lock?" );
  230.        L0 = select( "Yes", "No" );
  231.        if L0 = 0 then
  232.          if object.class <> NORMAL_DOOR then
  233.            writeln( "You can't break this kind of door." );
  234.          elsif random( 2 + adjustments(player.str) ) > 0 then
  235.            write( "You broke the lock!" );
  236.            if object.traptype = 1 then
  237.              voice( "Argh", 1000 );    ! 1000 = DCSOUNDS.VFL !
  238.              writeln( "Argh.. Poison trap!" );
  239.              player.poisoned = 1;
  240.            elsif object.traptype > 1 then
  241.              voice( "Explode", 1000 ); ! Play standard sound effect !
  242.              writeln( "Bomb Trap!" );
  243.              dec( player.hp, object.damage );
  244.              if player.hp = 0 then
  245.                writeln( player.name, " has died.." );
  246.              endif;
  247.            endif;
  248.            object.locktype = 0;
  249.            if object.block2 then
  250.              object.block = object.block2;
  251.            endif;
  252.          else
  253.            writeln( "It doesn't break!" );
  254.          endif;
  255.        else
  256.          writeln( "Ok." );
  257.        endif;
  258.      else
  259.        writeln( "It is not locked.." );
  260.      endif;
  261.      stats(-1); ! Restore Statistics !
  262.      STOP;
  263.  
  264.   :USE_KEYS
  265.      writeln( "Just 'Get' it and carry it in case you find a lock that" );
  266.      writeln( "the key can open!" );
  267.      STOP;
  268.  
  269.   :USE_BOOK
  270.      writeln( "To read it, just 'Look' at it.." );
  271.      STOP;
  272.  
  273.   :USE_GOLDSACK
  274.      L(1) = getnum("How many gold pieces do you want to put in it?",
  275.                          0, group.gold / 10) * 10;
  276.      if L(1) then
  277.        writeln( "You put ", $L1, " in the bag." );
  278.        inc( object.value, L(1) );
  279.        dec( group.gold, L(1) );
  280.      else
  281.        writeln( "Smart move.." );
  282.      endif;
  283.      STOP;
  284.  
  285.   :USE_TORCH
  286.   :USE_LANTERN
  287.      writeln( "Save your torches.. I haven't implemented LIGHT yet!" );
  288.      STOP;
  289.  
  290.   :USE_ROPE
  291.      writeln( "After fooling around with it for a while, you manage to" );
  292.      writeln( "get yourself tangled up..." );
  293.      STOP;
  294.  
  295.   :USE_HOOKS
  296.      voice( "Ouch", 1000 );
  297.      writeln( "Ouch! (it's sharp!)" );
  298.      STOP;
  299.  
  300.   :USE_MIRROR
  301.      writeln( "Yes, you are ugly, but that doesn't matter here.." );
  302.      STOP;
  303.  
  304.   :USE_SIGN
  305.      writeln( "It's not yours.  You can 'Read' it if you wish.." );
  306.      STOP;
  307.  
  308.   :USE_VEHICLE
  309.      if group.vehicle.count then
  310.        writeln( "You must first exit the one you are in!" );
  311.        STOP;
  312.      endif;
  313.      if object.x <> group.x and object.y <> group.y then
  314.        writeln( "You must be standing next to the ", object.name );
  315.      else
  316.        group.x = object.x;            ! Move over to it !
  317.        group.y = object.y;            
  318.        move( object, group.vehicle, 1 ); ! Now board the object !
  319.        if success then
  320.          writeln( "You are on riding the ", group.vehicle.name );
  321.        endif;
  322.      endif;
  323.      STOP;
  324.  
  325.   :USE_DOOR
  326.      if object.locktype then      ! Door is LOCKED !
  327.        gosub UNLOCK_OBJECT;
  328.        if object.locktype = 0 then ! Done !
  329.          STOP;
  330.        endif;
  331.        writeln( "You don't have the right key!  Break the lock?" );
  332.        if getstr( "Yes", "No" ) = 0 then
  333.          if random( 2 + adjustments(player.str) ) > 0 then
  334.            write( "You broke the lock!" );
  335.            if object.traptype = 1 then
  336.              voice( "Argh", 1000 ); ! 1000 = DCSOUNDS.VFL !
  337.              writeln( "Argh.. Poison trap!" );
  338.              player.poisoned = 1;
  339.            elsif object.traptype > 1 then
  340.              voice( "Explode", 1000 ); ! Play standard sound effect !
  341.              writeln( "Bomb Trap!" );
  342.              dec( player.hp, object.damage );
  343.              if player.hp = 0 then
  344.                writeln( player.name, " has died.." );
  345.              endif;
  346.            endif;
  347.            object.locktype = 0;
  348.          else
  349.            writeln( "It doesn't break!" );
  350.          endif;
  351.        else
  352.           writeln( "Ok." );
  353.        endif;
  354.      else
  355.        writeln( "It is not locked.." );
  356.      endif;
  357.      STOP;
  358.  
  359. !------------------------------------------------------------------------!
  360. :@EXIT ! Exit a VEHICLE (since this is an object we are talking about..)
  361. !------------------------------------------------------------------------!
  362.   if group.vehicle.count = 0 then
  363.     writeln("You are already on foot!" );
  364.     STOP;
  365.   endif;
  366.   drop( group.vehicle );
  367.   voice( "Exit", 1000 );
  368.   writeln( "You are now on foot.." );
  369.   STOP;
  370.  
  371. !------------------------------------------------------------------------!
  372. :@ATTACK ! Attack an object or a person !
  373. !------------------------------------------------------------------------!
  374.   if npc.count then
  375.     if npc.type = HOSTILE then
  376.       FIGHT;
  377.       !- Script ends when you 'FIGHT' -!
  378.     endif;
  379.     writeln( "Find some bad guys to fight!" );
  380.     STOP;
  381.   endif;
  382.   if object.type = CHEST then
  383.     if object.locktype then
  384.       writeln( "Instead of fighting it, try 'UNLOCK'!" );
  385.     else
  386.       writeln( "It's not even locked, why fight it?" );
  387.     endif;
  388.   else
  389.     writeln( "Why would you want to fight the ", object.name );
  390.   endif;
  391.   STOP;
  392.  
  393. !------------------------------------------------------------------------!
  394. !--  SCRIPT SUBROUTINES ARE GROUPED HERE AT THE END.  THIS IS A CHOICE --!
  395. !--  NOT A REQUIREMENT.  IT MAKES THE MAIN SCRIPT CODE ABOVE A LITTLE  --!
  396. !--  BIT EASIER TO FOLLOW.  ---------------------------------------------!
  397. !------------------------------------------------------------------------!
  398.  
  399.  
  400. !------------------------------------------------------------------------!
  401. ! STILLKICKING: Subroutine to verify that the player is alive before     !
  402. ! allowing him/her/it to perform an action.                              !
  403. !------------------------------------------------------------------------!
  404. :STILLKICKING
  405.   if player.hp = 0 then
  406.     writeln( player.name, " is dead!" );
  407.     STOP;
  408.   endif;
  409.   RETURN;
  410.  
  411. !------------------------------------------------------------------------!
  412. !
  413. ! SUBROUTINE: DESCRIBE
  414. !
  415. ! This routine is called from @LOOK, @EXAMINE and by the ANALYZE spell
  416. ! to describe a given item.
  417. !
  418. !------------------------------------------------------------------------!
  419. :DESCRIBE
  420. !------------------------------------------------------------------------!
  421.  
  422. ! First, handle the case where you are looking at a CHARACTER
  423.  
  424.   if npc.count then
  425.     if npc.picture >= 0 then
  426.       viewpcx( npc );
  427.       if success then
  428.         pause;
  429.       endif;
  430.       paint(window); ! Assumes the picture fits in the window, must use !
  431.                      ! 'paint(screen)' otherwise !
  432.     endif;
  433.     write( "Name: ", npc.name, ", Type: ", npc.type );
  434.     if npc.type = HOSTILE and npc.weapon.count then
  435.       write( ", Weapon: ", npc.weapon.name, ", Damage: ", npc.weapon.damage, ", Range: ", npc.weapon.range );
  436.     endif;
  437.     if L(255) then
  438.       write( ", Class: ", npc.class, ", Lvl: ", npc.level, ", AC: ", npc.ac, ", HP: ", npc.hp );
  439.     endif;
  440. write("VFL=",npc.voice," IDX=",npc.index," STATS=",npc.stats," SCR=",npc.script);
  441. group.gold = 100000;
  442.     writeln(".");
  443.     STOP;
  444.   endif;
  445.   ! Not looking at a character, call the 'DESCOBJ' script to look at an
  446.   ! object.
  447.   runscript( "DESCOBJ", LOOK );
  448.  
  449. !------------------------------------------------------------------------!
  450. :UNLOCK_OBJECT
  451. !------------------------------------------------------------------------!
  452.    L0 = 0;
  453.    :UCLOOP
  454.       setbp( player, L0 );
  455.       if player.bp.count then
  456.         if player.bp.type = KEYS and player.bp.keytype = object.locktype then
  457.           writeln( object.name, " unlocked.." );
  458.           object.locktype = 0;
  459.           if object.block2 then
  460.             object.block = object.block2;
  461.           endif;
  462.           return;
  463.         endif;
  464.       endif;
  465.       inc( L0 );
  466.       if L0 < 16 goto :UCLOOP;
  467.    RETURN;
  468.  
  469.